package cn.frank.framework.caesar.module.ai.qwen.domain.vo.page;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.SchemaProperty;
import lombok.Data;
import lombok.experimental.Accessors;

@Schema(description = "分页对象")
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@Accessors(chain = true)
public class PagePojo {

    public PagePojo(){}
    public PagePojo(Integer pageNum, Integer pageSize){
        this.pageNum=pageNum;
        this.pageSize=pageSize;
    }

    public PagePojo(Integer pageNum, Integer pageSize, String sortField, String order){
        this.pageNum=pageNum;
        this.pageSize=pageSize;
        this.sortField=sortField;
        this.order=order;
    }

    public Integer getPageSize() {
        //防止数据为空
        if(ObjectUtil.isNull(this.pageSize)||this.pageSize.intValue()==0){
            this.pageSize=10;
        }
        return pageSize;
    }


    public Integer getPageNum() {
        //防止数据为空
        if(ObjectUtil.isNull(this.pageNum)||this.pageNum.intValue()==0){
            this.pageNum=1;
        }
        return pageNum;
    }


    public String getSortField() {
        return this.sortField;
    }

    public String getOrder() {
        return this.order;
    }



    @SchemaProperty(name = "每页显示条数")
    private Integer pageSize=10;

    @SchemaProperty(name = "页码数")
    private Integer pageNum=1;

    @SchemaProperty(name = "排序参数")
    private String sortField;

    @SchemaProperty(name = "排序类型：asc、desc")
    private String order;

}
